Skip to content

Preserve endianness when duplicating bytebuffers#2865

Merged
riccardobl merged 2 commits into
jMonkeyEngine:masterfrom
riccardobl:byteorder
Jun 10, 2026
Merged

Preserve endianness when duplicating bytebuffers#2865
riccardobl merged 2 commits into
jMonkeyEngine:masterfrom
riccardobl:byteorder

Conversation

@riccardobl

@riccardobl riccardobl commented Jun 9, 2026

Copy link
Copy Markdown
Member

This currently does not fix anything in the engine, since in one way or the other the endianess was restored manually, or unimportant in jme code.

This is mostly for correctness and to avoid surprises in the future.

gemini-code-assist[bot]

This comment was marked as outdated.

@riccardobl

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new utility class ByteBufferUtils with a duplicate method that duplicates a ByteBuffer while preserving its byte order. It replaces direct calls to ByteBuffer.duplicate() with this utility across several classes (including AndroidGL, EnvMapUtils, GLRenderer, BufferObject, and others) and updates buffer allocations to explicitly maintain byte order. Feedback suggests adding a defensive null check to ByteBufferUtils.duplicate to prevent potential NullPointerExceptions, and adding a null check while simplifying the duplication logic in BufferObject.setData to avoid side effects on the caller's buffer.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread jme3-core/src/main/java/com/jme3/util/ByteBufferUtils.java
@riccardobl riccardobl changed the title Preserve endianness when duplicating bytebuffer Preserve endianness when duplicating bytebuffers Jun 9, 2026
@riccardobl riccardobl merged commit 1c9d49e into jMonkeyEngine:master Jun 10, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant